<?php
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::_('exercise.stylesheet');
$canDo = ExercisesHelper::getActions();
$user = JFactory::getUser();
$userId = $user->get('id');
$item = $this->item;

$member = JFactory::getUser($item->userid);
?>
<script type="text/javascript">
    Joomla.submitbutton = function(task)
    {
        if (task == 'result.cancel' || document.formvalidator.isValid(document.id('result-form'))) {
            Joomla.submitform(task, document.getElementById('result-form'));
        }
    }
</script>

<form action="<?php echo JRoute::_('index.php?option=com_exercises&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="result-form" class="form-validate">
    
    <div class="form-horizontal">
        <?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?>

        <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', JText::_('COM_EXERCISES_GROUP_LABEL_PUBLISHING_DETAILS', true)); ?>
        <div class="row-fluid">
            <div class="span12">
                <div class="control-group ">
                    <div class="control-label" style="padding: 0"><label title="" class="hasTooltip" data-original-title="<?php echo JText::_('COM_EXERCISES_HEADING_RESULTS_NAME_TIP') ?>"><?php echo JText::_('COM_EXERCISES_HEADING_RESULTS_NAME') ?>: </label></div>
                    <div class="controls"><?php echo $member->name; ?></div>
                </div>
                <table class="table table-striped" id="articleList">
                    <thead>
                        <tr>

                            <th>
                                <?php echo JText::_('COM_EXERCISES_HEADING_QUESTION'); ?>
                            </th>
                            <th width="35%">
                                <?php echo JText::_('COM_EXERCISES_HEADING_QUESTION_CONTENT'); ?>
                            </th>
                            <th width="15%">
                                <?php echo JText::_('COM_EXERCISES_HEADING_USER_ANSWER_CONTENT'); ?>
                            </th>
                            <th width="5%">
                                <?php echo JText::_('COM_EXERCISES_FIELD_ANSWER_RESULT_LABEL'); ?>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($item->resultdetail as $result): ?>
                        <tr>

                            <td>
                                <?php echo $result->name; ?>
                            </td>
                            <td>
                                <?php echo $result->question; ?>
                            </td>
                            <td>
                                 <?php echo $result->answer; ?>
                            </td>
                            <td>
                                <?php echo $result->point; ?>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
           
        </div>
        <?php echo JHtml::_('bootstrap.endTab'); ?>
        <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'publishing', JText::_('JGLOBAL_FIELDSET_PUBLISHING', true)); ?>
        <div class="row-fluid form-horizontal-desktop">
            <div class="span6">                 
                <?php echo JLayoutHelper::render('joomla.edit.global', $this); ?>            
                
            </div>
            <div class="span6">
                <?php echo JLayoutHelper::render('joomla.edit.publishingdata', $this); ?>
                <?php echo $this->form->getControlGroups('metadata'); ?>                
            </div>
        </div>
        <?php echo JHtml::_('bootstrap.endTab'); ?>

        <?php echo JHtml::_('bootstrap.endTabSet'); ?>
    </div>

    <input type="hidden" name="task" value="" />
    <?php echo JHtml::_('form.token'); ?>
</form>